﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="H2.NET.Web.Management.Config.Index" %>
<%@ Register src="../../UserControls/Pager.ascx" tagname="Pager" tagprefix="uc1" %>
<%@ Register src="../../UserControls/Toolbar.ascx" tagname="Toolbar" tagprefix="uc1" %>
<form id="pagerForm" onsubmit="return navTabSearch(this);" action="<%= Request.RawUrl %>" method="post">

    <input type="hidden" name="pageNum" value="<%= PageNumber %>" />
    <input type="hidden" name="numPerPage" value="<%= PageSize %>" />

<div class="pageHeader">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td>
					<label>字典名称：</label><input type="text" name="name" size="30" value="<%= name %>" />
				</td>
			</tr>
		</table>
		<div class="subBar">
            <span class="info_clear">符合条件的记录，共有 <strong><%= TotalItemCount %></strong>条。</span>
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
                <li><div class="button"><div class="buttonContent"><button type="reset">重置</button></div></div></li>
			</ul>
		</div>
	</div>
</div>
</form>
<form id="form1" runat="server">
<asp:hiddenfield runat="server" id="hd_parentId"></asp:hiddenfield>
<asp:hiddenfield runat="server" id="rel"></asp:hiddenfield>
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <uc1:Toolbar ID="Toolbar1" runat="server" />
        </ul>
    </div>
    <table class="table" width="100%" layoutH="137">
        <thead>
            <tr>
                <th style="width: 5%;">序号</th>
                <th align="center" style="width:30%;">名称</th>
                <th align="center" style="width:30%;">值</th>
                <th align="center" style="width:30%;">编码</th>
                <th align=center style="width:30%">排序</th>
            </tr>
        </thead>
        <tbody>
            <asp:Repeater ID="rpt_configs" runat="server">
                <ItemTemplate>
                    <tr rel='<%# Eval("configid") %>' target="selectedId">
                    <td class="fixedcol" style="width: 5%;"><%# Container.ItemIndex + 1%></td>
                    <td align="center" style="width:24%;"><%# Eval("Name")%></td>
                    <td align="center" style="width:24%"><%# Eval("Value")%></td>
                    <td align="center" style="width:24%;"><%# Eval("Code")%></td>
                    <td align="center" style="width:24%;"><%# Eval("Seq")%></td>
                </tr> 
                </ItemTemplate>
            </asp:Repeater>
        </tbody>
    </table>
</div>
<uc1:Pager ID="Pager1" runat="server" />
</form>
<script type="text/javascript">

   /* $(function MenuAjax() {
        $.ajax({
            type: 'POST',
            url: "Management/Config/Index.aspx?action=menu",
            dataType: "json",
            cache: false,
            success: function (json) {
                
            },
            error: DWZ.ajaxError
        });

    });
    */

    function menu() {

        var pId = $("#hd_parentId").val();
        if (pId == "") {

        $.ajax({
            type: 'POST',
            url: "Management/Config/Index.aspx?action=menu",
            dataType: "html",
            cache: false,
            success: function (html) {
                $(".folder44").parent().parent().next().children().children().not(":first").remove();
                $(".folder44").parent().parent().next().children().append(html);
                $("a[rel^=ConfigIndex_]").each(function () {
                    $(this).click(function (event) {
                        var $this = $(this);
                        var title = $this.attr("title") || $this.text();
                        var tabid = $this.attr("rel") || "_blank";
                        var fresh = eval($this.attr("fresh") || "true");
                        var external = eval($this.attr("external") || "false");
                        var url = unescape($this.attr("href")).replaceTmById($(event.target).parents(".unitBox:first"));
                        DWZ.debug(url);
                        if (!url.isFinishedTm()) {
                            alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg"));
                            return false;
                        }
                        navTab.openTab(tabid, url, { title: title, fresh: fresh, external: external });

                        event.preventDefault();
                    });
                });
            },
            error: DWZ.ajaxError
        });
    }
}
    


    function ConfigCreate(url, rel, title) {
        var pId = $("#hd_parentId", navTab.getCurrentPanel()).val();
        $.pdialog.open(url + "?pId=" + pId + "&rel="+pId, rel, title, { width: 550, height: 260, mask: true });
        return false;
    }
    function ConfigEdit(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        var pId = $("#hd_parentId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        if (id) {
            $.pdialog.open(url + "?id=" + id + "&rel=" + pId + "&pId=" + pId, rel, title, { width: 550, height: 260, mask: true });
        } else {
            $.pdialog.open(url + "?id=" + pId + "&rel=" + pId + "&pId=" + pId, rel, title, { width: 550, height: 260, mask: true });
        }
        return false;
    }
    function ConfigDelete(url, rel, title) {
        var id = $("#selectedId", navTab.getCurrentPanel()).val();
        if (!id) {
            alertMsg.warn("请先选择一条数据！");
            return false;
        }
        alertMsg.confirm(title, {
            okCall: function () {
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: { id: id, title: title },
                    dataType: "json",
                    cache: false,
                    success: function (json) {
                        menu();
                        DWZ.ajaxDone(json);
                        navTabSearch($("#pagerForm", navTab.getCurrentPanel()));
                    },
                    error: DWZ.ajaxError
                });
            }
        });
        return false;
    }
   
</script>
